require('@/public.js');
require('./css/commissionList.css');
require('@/assets/css/drag-up.scss');
import { getWindowWidthAndHeight } from '@/utils/utils';

Jsborya.ready(function () {


	var app = new Vue({
		el: '#app',
		data: {
			isPullLoad: true,//上拉加载开关
			isHaveMore: 0,//是否还有更多号码
			firstLoad: true,
			pageSize: 12,
			lastId: 0,//当前页数
			boxHeight: '400px',
			dataList: [],
			total: 0,
		},
		created () {
			Jsborya.webviewLoading({ isLoad: false });//关闭app加载层
		},
		mounted () {
			const vm = this;

			// 获取窗口宽高
			let { windowHeight } = getWindowWidthAndHeight();
			vm.boxHeight = windowHeight - 84 + 'px';

			Jsborya.getUserInfo(function (data) {
				vm.userInfo = data;

				vm.getList();
			});
		},
		methods: {
			getList: function (closeLoad) {//获取首屏号卡数据
				const vm = this;

				var json = {
					'params': {
						'pageSize': vm.pageSize,
						'lastId': vm.lastId,
					},
					'userInfo': vm.userInfo
				};

				vm.isHaveMore = false;
				var pull = function (data) {//上拉时，合并数据列表
					vm.dataList = vm.dataList.concat(data);
				};
				if (json.params.lastId == 0) {
					document.getElementById('dataBox').scrollTop = 0;
				}
				vm.AJAX('/jleas/w/account/withdrawList', json, function (data) {
					vm.firstLoad = false;
					vm.alreadyPhone = '';
					vm.isPullLoad = true;
					vm.count = data.data.count;
					if (data.data.list.length) vm.lastId = data.data.list[data.data.list.length - 1].ordId;
					vm.total = vm.numberFormat(data.data.totalFee);

					closeLoad ? pull(data.data.list) : vm.dataList = data.data.list;
					if (json.params.lastId && data.data.list.length == 0) vm.isHaveMore = true;
				}, closeLoad);
			},
			pullLoad: function (e) {//上拉执行
				e.preventDefault();
				var vm = this, obj = document.getElementById('dataBox');

				if (vm.isPullLoad && obj.scrollHeight <= (obj.scrollTop + obj.offsetHeight) && !vm.isHaveMore) {
					vm.isPullLoad = false;
					vm.getList(true);
				} else {
					vm.isHaveMore = false;
				}
			},
			jumpToDetails (ordId) {
				// Jsborya.pageJump({
				// 	url:'commissionOutListDetails.html?ordId='+ordId,
				// 	stepCode:'999',
				// 	depiction:'提现记录详情'
				// })
			}
		}
	});


});